package com.yuan.config;

import com.yuan.bean.Person;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

@Configuration
@ComponentScan(value = "com.yuan", excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
}, includeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Service.class})
}, useDefaultFilters = false) //自动扫描的包
//excludeFilters = ComponentScan.Filter[] : 指定扫描的时候按照什么规则排除哪些组件
//includeFilters = ComponentScan.Filter[] : 指定扫描的时,只需要包含哪些组件,还需配合禁用掉默认规则一起使用
//useDefaultFilters = false : 禁用自动扫描的的默认规则

/*
1.如果是Java8版本，则可以多次使用@ComponentScan注解
@ComponentScan(...)
@ComponentScan(...)*/

/*
2.如果Java8之前的版本，则使用@ComponentScans注解来多次使用@ComponentScan注解
@ComponentScans(
        value = {
                @ComponentScan(value = "com.yuan", excludeFilters = {
                        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class})
                }, includeFilters = {
                        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Service.class})
                }, useDefaultFilters = false) //自动扫描的包
        }
)*/
public class MyConfigOne {
    @Bean("person")
    public Person person(){
        return new Person("李四",25);
    }
}
